//
//  ExaminationPaperBeginCell.m
//  JPWords
//
//  Created by 梁淑婷 on 2024/6/2.
//

#import "ExaminationPaperBeginCell.h"

@interface ExaminationPaperBeginCell()

@property(nonatomic,strong)UIView *bgView;
@property(nonatomic,strong)UILabel *titleLabel;
@property(nonatomic,strong)UIButton *startBtn;

@end

@implementation ExaminationPaperBeginCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    self.backgroundColor = KbgColor;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.bgView = [[UIView alloc]init];
    self.bgView.backgroundColor = [UIColor whiteColor];
    self.bgView.layer.cornerRadius = 10;
    self.bgView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.bgView];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(@16);
        make.right.mas_equalTo(@-16);
        make.top.mas_equalTo(@0);
        make.height.mas_equalTo(@120);
    }];
    
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.font = JPUIFontPingFangSCRegular(16);
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.textColor = KFontBlackColor;
    [self.bgView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(@20);
        make.right.mas_equalTo(@-20);
        make.top.mas_equalTo(@20);
        make.height.mas_equalTo(@22);
    }];
    
    self.startBtn = [[UIButton alloc]init];
    [self.startBtn setTitle:@"开始考试" forState:UIControlStateNormal];
    [self.startBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.startBtn.titleLabel.font = JPUIFontPingFangSCMedium(16);
    self.startBtn.backgroundColor = KThemeColor;
    self.startBtn.layer.cornerRadius = 21;
    self.startBtn.layer.masksToBounds = YES;
    [self.startBtn addTarget:self action:@selector(startBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.bgView addSubview:self.startBtn];
    [self.startBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(@20);
        make.bottom.mas_equalTo(@-20);
        make.right.mas_equalTo(@-20);
        make.height.mas_equalTo(@42);
    }];
    
    
}

- (void)setModel:(ExamPaperYearListModel *)model{
    _model = model;
    self.titleLabel.text = [NSString stringWithFormat:@"考试时间：%@分钟",model.time];
}


#pragma mark - 开始
-(void)startBtnClick{
    if (self.delegate && [self.delegate respondsToSelector:@selector(testTap:)]){
        [self.delegate testTap:self];
    }
}

@end
